package com.cizzy.video.entity.dao;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cizzy.video.entity.dto.VideoDTO;
import com.cizzy.video.entity.vo.VideoVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * <p>
 * 
 * </p>
 *
 * @author crissy-月下闲人
 * @since 2023-10-29
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("video")
public class VideoDAO implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("video_id")
    private Long videoId;

    private Timestamp createAt = new Timestamp(System.currentTimeMillis());

    private Long userId;

    private String title;

    private String description;

    private String cryptoTitle;

    private String type;

    private String videoUrl;

    public VideoDAO(VideoVo videoVo) {
        this.title = videoVo.getTitle();
        this.description = videoVo.getDescription();
        this.type = videoVo.getType();
        this.createAt = new Timestamp(System.currentTimeMillis());
    }

    public void convertFromVideoDTO(VideoDTO videoDTO) {
        this.videoId = videoDTO.getVideoId();
        this.createAt = videoDTO.getCreateAt();
        this.userId = videoDTO.getAuthor().getUserId();
        this.title = videoDTO.getTitle();
        this.description = videoDTO.getDescription();
        this.cryptoTitle = videoDTO.getCryptoTitle();
        this.type = videoDTO.getType();
        this.videoUrl = videoDTO.getVideoUrl();
    }
}
